<?php

namespace app\admin\controller\users;

use app\common\controller\Backend;
use think\Db;
use think\Env;
// 声明命名空间
use Obs\ObsClient;

/**
 * 大客户-邀请微信详情
 *
 * @icon fa fa-circle-o
 */
class Bigs extends Backend
{

    // 无需鉴权的接口,*表示全部
    protected $noNeedRight = ['*'];
    protected $relationSearch = true;

    /**
     * @var \app\admin\model\User
     */
    protected $model = null;
    private $redis;

    public function _initialize()
    {
        parent::_initialize();
        $this->model = new \app\admin\model\Users;

        $this->redis = redis(Env::get('redis.host'), Env::get('redis.port'), Env::get('redis.pwd'), Env::get('redis.db'));
    }

    /**
     * 查看
     */
    public function index()
    {

        //设置过滤方法
        $this->request->filter(['strip_tags', 'trim']);
        if ($this->request->isAjax()) {

            $arr = request()->param();
            $wheres = [];

            if (isset($arr['big_id'])){
                $wheres['big_id'] = $arr['big_id'];
            }

            list($where, $sort, $order, $offset, $limit) = $this->buildparams();

            $list = $this->model
                ->with([
                    'big' => function ($query) {
                        $query->withField('id,name');
                    },
                ])
                ->where($where)
                ->where($wheres)
                //->where('admin_id', 'in', [0])
                ->order('binding_time', 'desc')
                ->paginate($limit);

            $result = array("total" => $list->total(), "rows" => $list->items());

            return json($result);
        }

        return $this->view->fetch();
    }


}
